<?php

include 'resources_controller.php';

if ($_GET['action'] == "view") {
    $json = $HTTP_RAW_POST_DATA;
    if ($json != NULL) {
        echo viewResources($json);
    } else {
        echo 'Invalid Request';
    }
} else if ($_GET['action'] == "viewResourcesMhs") {
    $json = $HTTP_RAW_POST_DATA;
    if ($json != NULL) {
        echo viewResourcesMhs($json);
    } else {
        echo 'Invalid Request';
    }
} else if ($_GET['action'] == "add") {
    $json = $HTTP_RAW_POST_DATA;
    if ($json != NULL) {
        if (createResource($json))
            echo 'Create Success.';
        else
            echo 'Create Failed!';
    } else {
        echo 'Invalid Request';
    }
} else if ($_GET['action'] == "update") {
    $json = $HTTP_RAW_POST_DATA;
    if ($json != NULL) {
        if (updateResource($json))
            echo 'Update Success.';
        else
            echo 'Update Failed!';
    } else {
        echo 'Invalid Request';
    }
} else if ($_GET['action'] == "delete") {
    $json = $HTTP_RAW_POST_DATA;
    if ($json != NULL) {
        if (deleteResource($json))
            echo 'Delete Success.';
        else
            echo 'Delete Failed!';
    } else {
        echo 'Invalid Request';
    }
} else {
    echo 'Action not defined!';
}
?>
